package billing

import (
	"context"

	"gitee.com/spume/common_service/app/billing/api/billing/v1"
	"gitee.com/spume/common_service/app/billing/internal/service"
	"github.com/gogf/gf/v2/errors/gerror"
)

func (c *ControllerV1) BillingCreate(ctx context.Context, req *v1.BillingCreateReq) (res *v1.BillingCreateRes, err error) {
	res = &v1.BillingCreateRes{}
	billIds, err := service.Billing().CreateWith(ctx, req.TenantId, req.BillingBatch)
	if err != nil {
		return
	}
	if len(billIds) == 0 {
		err = gerror.New("billing nums error")
		return
	}

	res.BillId = billIds[0]

	return
}
